<template>
  <div class="home">
    <v-header :seller="seller"></v-header>
    <div class="tab">
      <div class="tab-item">
        <router-link to="/home/goods">商品</router-link>
      </div>
      <div class="tab-item">
        <router-link to="/home/rating">评论</router-link>
      </div>
      <div class="tab-item">
        <router-link to="/home/seller">商家</router-link>
      </div>
    </div>
    <keep-alive>
      <router-view :seller="seller" :foods="foods" v-on:sendfoods="sendfoods"></router-view>
    </keep-alive>
  </div>
</template>

<script>
import VHeader from "../components/header/header.vue";
import {seller} from "../api/seller/index.js";

export default {
  name: "Home",
  data() {
    return {
      seller: {},
      foods: []
    }
  },
  created() {
    seller(1).then(resp => {
      const {data} = resp;
      this.seller = data;
    })
  },
  components: {VHeader},
  methods: {
    sendfoods(foods) {
      this.foods = foods;
    }
  }
}
</script>

<style scoped lang="stylus">
@import "../common/css/mixin.styl";
.home
  .tab
    display flex
    width 100%
    height 40px
    line-height 40px
    border-1px(rgba(7, 17, 27, 0.5))

    .tab-item
      flex 1
      text-align center

      & > a
        display block
        font-size 18px
        color rgb(77, 85, 93)

        &.router-link-exact-active
          color rgb(240, 20, 20)
</style>